﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XProject.DataVisit.Model;
using System.Web;
using XProject.DataVisit.Factory;
using XProject.DataVisit.Model.Advertisement;

namespace XProject.DataVisit.Handler.View.Advertisement
{
    public class AdvertisementModelView:AbstractView
    {
        private UserInfo CurrentUser;
        public override void init()
        {
            if (HttpContext.Current.Session["UserInfo"] != null)
            {
                CurrentUser = HttpContext.Current.Session["UserInfo"] as UserInfo;
                base.init();
            }
            else
            {
                return;
            }
        }


        public void GetAdModelType()
        {
            JsonResponse.ResponseObject= DaoFactory.AdvertisementModelDao.GetAll();
        }

        public void AddAdModelType()
        {
            var model = JsonRequest.GetParam<AdvertisementModel>("model");
            model.LastUpdate = DateTime.Now;
            JsonResponse.ResponseObject = DaoFactory.AdvertisementModelDao.Save(model);
        }

        public void UpdateAdModelType()
        {
            var model = JsonRequest.GetParam<AdvertisementModel>("model");
            JsonResponse.ResponseObject = DaoFactory.AdvertisementModelDao.Update(model);
        }

        public void DelAdModelType()
        {
            var model = JsonRequest.GetParam<AdvertisementModel>("model");
            JsonResponse.ResponseObject = DaoFactory.AdvertisementModelDao.Delete(model);
        }
    }
}
